//package com.qike.duola.utils;
//
//import com.dingtalk.api.DefaultDingTalkClient;
//import com.dingtalk.api.DingTalkClient;
//import com.dingtalk.api.request.OapiFileUploadSingleRequest;
//import com.dingtalk.api.response.OapiFileUploadSingleResponse;
//import com.taobao.api.ApiException;
//import com.taobao.api.FileItem;
//import com.taobao.api.internal.util.WebUtils;
//import org.apache.commons.io.FileUtils;
//import org.springframework.stereotype.Component;
//import org.springframework.web.multipart.MultipartFile;
//
//import java.io.*;
//
///**
// * @Author: Eric.zhou
// * @Date: 2020/9/25 14:49
// */
//@Component
//public final class DingDingUtil {
//
//
//    /**
//     * 钉钉上传文件
//     *
//     * @param multipartFile
//     */
//    public static void upLoadFile(MultipartFile multipartFile) throws IOException, ApiException {
//        OapiFileUploadSingleRequest request = new OapiFileUploadSingleRequest();
//        request.setFileSize(multipartFile.getSize());
//        request.setAgentId("135717601");
//        DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/file/upload/single?" + WebUtils.buildQuery(request.getTextParams(), "utf-8"));
//        // 必须重新new一个请求
//        File file = null;
//        String originalFilename = multipartFile.getOriginalFilename();
//        String[] filename = originalFilename.split(".");
//        file = File.createTempFile(filename[0], filename[1]);
//        multipartFile.transferTo(file);
//        request.setFile(new FileItem(file));
//        file.deleteOnExit();
//        OapiFileUploadSingleResponse response = client.execute(request, DingDingTokenUtil.getToken());
//    }
//
//
//    public static void main(String[] args) throws IOException {
//        InputStream inputStream = null;
//        File file = new File("https://cdn.fledchina.com/123.pdf");
//        //结果是cxyapi和cxyapi1在同一目录
//        FileUtils.copyDirectory(file, new File("D:/cxyapi1"));
//    }
//
//}
